import requests

shipment_headers = {
    'User-Agent':
    'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36',
    'Content-Type': 'application/x-www-form-urlencoded',
    'Referer': 'https://www.shipmentlink.com/servlet/TDB1_CargoTracking.do',
}

def make_shipment_coookie():
    url = 'https://www.shipmentlink.com/servlet/TDB1_CargoTracking.do'
    req = requests.get(url, headers=shipment_headers)
    cookies = requests.utils.dict_from_cookiejar(req.cookies)  # 转成字典格式
    # cookies['TDB1_Function_Type'] = 'quick'
    # print(cookies, type(cookies))
    cookie_id = cookies['JSESSIONID']

    cookies = {'TDB1_Function_Type': 'quick', 'JSESSIONID': str(cookie_id)}
    return cookies


def post_http(url,post_data,request_cookie,headers):
    resp = requests.post(url, headers=headers, data=post_data, cookies=request_cookie)
    return resp.text

if __name__ == '__main__':
    print(make_shipment_coookie())